package com.tianqu.tms.dao;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.tianqu.tms.core.exception.TmsDaoException;
import com.tianqu.tms.dto.CheckInfoPicDto;

public class CheckInfoPicDaoImp extends TmsDao implements CheckInfoPicDao {

	protected CheckInfoPicDaoImp() throws TmsDaoException {
		super();
		
	}
    
	/* （非 Javadoc）
	 * @see com.tianqu.tms.dao.CheckInfoPicDao#saveImage(com.tianqu.tms.dto.CheckInfoPicDto)
	 */
	@Override
	public void saveImage(CheckInfoPicDto dto)throws TmsDaoException{
		PreparedStatement ps = null;
		ResultSet rs = null;
		try {
			conn = super.getConnection();
			StringBuffer sql = new StringBuffer();
			sql.append("INSERT INTO ");
			sql.append(TmsTableNames.TMS_CHECK_CAR_PIC);
			sql.append(" (");
			sql.append(" SERIAL,  ");
			sql.append(" CARIMAGES1,  ");
			sql.append(" CARIMAGES2,  ");
			sql.append(" CARIMAGES3,  ");
			sql.append(" CARIMAGES4,  ");
			sql.append(" INSERTUSERID,  ");
			sql.append(" UPDATEUSERID,  ");
			sql.append(" INSERTTIME,  ");
			sql.append(" UPDATETIME  ");
			sql.append(" )VALUES(  ");
			sql.append(" ?,?,?,?,?,?,?,SYSDATE(),SYSDATE()  ");
			sql.append(" )  ");
			ps = conn.prepareStatement(sql.toString());
			
			ps.setString(1,dto.getSerial());
			ps.setString(2,dto.getCarImages1());
			ps.setString(3,dto.getCarImages2());
			ps.setString(4,dto.getCarImages3());
			ps.setString(5,dto.getCarImages4());
			ps.setInt(6, dto.getInsertUserId());
			ps.setInt(7, dto.getUpdateUserId());
			// 执行sql
			ps.executeUpdate();
		} catch (SQLException e) {
			throw new TmsDaoException(e.toString());
			
		} finally {
			close(rs,ps);
		}
		
	}
}
